Skip to content

fix(app-shell): Home sends its deployment-notice, authorized-clients and API-key reads once per load - #34097

Merged
objectstack-fleet[bot] merged 7 commits into
mainfrom
claude/project-thread-fopr6k
Nov 15, 2026
Merged

objectstack-fleet[bot] merged 7 commits into
mainfrom
claude/project-thread-fopr6k

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Steve · project thread

Fixes #28085

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:首页冷加载时,部署提示、已授权 AI 助手、API 密钥这三个读取各只发一次(之前在打包后的控制台上分别是 2 次、3 次、3 次);列表页本来就每个 URL 只读一次,不变,现在由一个新的请求计数测试钉住(带消融)。
  • 为什么改:首页先画一帧完整页面、再切成"加载中"、再画一遍,里面的组件被挂载两次;另外"连接 AI 助手"卡片和管理员首次使用清单各自读同一份数据。每次打开首页白白多 5 次请求。
  • 风险与回滚:产品代码只动 @object-ui/app-shell 两个文件(另加一个控制台测试文件);首页现在在 /me/apps 回答之前显示"加载中"(这本来就是该标志声明的行为)。回滚即 revert 本 PR。
  • 先看:ui/packages/app-shell/src/hooks/useLauncherApps.tsx(firstReadDue)、ui/packages/app-shell/src/console/connect/connectedAccess.ts(共享读取的生命周期)。
  • 两分钟验证:pnpm --dir ui exec vitest run packages/app-shell/src/hooks/__tests__/useLauncherApps-26838.test.tsx packages/app-shell/src/console/connect/ConnectAgentWidget.connected-30898.test.tsx,预期 29 个用例全绿;列表页钉子:pnpm --dir ui exec vitest run apps/console/src/__tests__/App.listPageBootReadsOnce-28085.test.tsx,预期 1 个用例绿。
  • 需要你做的:无,席位落地。

What changes

Step 0 measured the card on a production console build (pnpm console:build, served by objectstack dev --ui --fresh from examples/app-showcase, seeded admin, headless Chromium 1440×900, a fresh page per load after sign-in, GETs under /api/ counted from navigation to network idle plus 3 s), on main bc6b7ffd:

  • List page (showcase_task ×4, showcase_account ×1): every URL is read once. auth/get-session, meta/app, auth/me/permissions and me/apps read 1 each, and meta/object?package, sys_user_preference and me/localization read 1 each too. The doubling the card names is still React.StrictMode's development replay, which this PR does not touch.
  • Home (×1, then ×2 with response times): GET /api/settings/deployment/notice ×2, GET /api/v1/auth/authorized-clients ×3, and the sys_api_key list ×3. None of them overlapped: each repeat started after the previous one had answered. So sharing an in-flight request (the card's "Wanted") could not remove them. The causes, traced on the Console dev server with StrictMode turned off locally (a local edit, restored) and a React DevTools hook recording mounts:
  1. Home mounted its children twice. HomePage waits on useLauncherApps().pending so it never draws a tile /me/apps then hides. LauncherAppsProvider set pending only from its effect, after the first commit, so the first frame had nothing pending and nothing narrowed. Home drew its page (mounting DeploymentNotice and ConnectAssistantCard, which read on mount), switched to its loading state when the effect published pending, then drew the page again when the answer came. Now the provider answers pending from the render that makes the first read due. Home draws the page once, after the answer. This also removes the first frame that drew a hidden app's tile, which the hook's own doc says never happens.
  2. Two readers of one answer. Home draws the Connect an AI Assistant card and, for an administrator, the first-run checklist. Both call useConnectedAccess, and each owned its own effects, so each sent authorized-clients and the sys_api_key list. The checklist's reader enables later (after the settings read), so its requests came after the card's had answered. useConnectedAccess now reads through a store shared by every reader mounted at the same time, keyed by adapter and person. A reader that mounts while the entry lives joins its answer or its reads in flight. A change to sys_api_key or sys_oauth_consent re-reads that record once for all readers. The entry is dropped with its last reader, so a page mounted later reads afresh, as it did before. The store's subscribe/getSnapshot pair is keyed on the adapter and person outside React, not on a memoised callback (ui AGENTS.md chore: version packages #10).

Both are one-place fixes at the source of each repeat. Neither is a per-call-site guard.

Readings: production console, before and after

Before (main bc6b7ffd), Home, one load: 35 GETs; repeated URLs deployment/notice ×2, authorized-clients ×3, sys_api_key list ×3. Timeline of the repeats (ms from navigation, start → end):

deployment/notice     977 → 1075   1116 → 1305
authorized-clients    979 → 1098   1117 → 1335   1375 → 1430
sys_api_key list      979 → 1109   1119 → 1342   1376 → 1433

After (head of this PR, console rebuilt), Home ×3: 30 GETs each, no URL repeated; deployment/notice 1, authorized-clients 1, sys_api_key list 1, me/apps 1, meta/app 1, me/permissions 1, get-session 1.

List page, before ×5 and after ×3 (showcase_task, showcase_account): 26 GETs each, no URL repeated; the card's four reads 1 each (meta/app and meta/app/showcase_app/bundle are two different URLs).

Dev server, StrictMode off, mounts recorded through a React DevTools hook (before the fix): DeploymentNotice and ConnectAssistantCard mounted twice under the same HomePage element, each mount followed by its reads; after fix 1, once; after fix 2, authorized-clients and the sys_api_key list are sent once, with the checklist mounted.

Tests

  • useLauncherApps-26838.test.tsx, new top-level describe the first /me/apps read is pending from the first render: a page behind Home's gate mounts once, so a child that reads on mount reads once per load (a request count); pending is true in the very first render when a read is due; and false when none is due (no user, metadata loading, no apps).
  • ConnectAgentWidget.connected-30898.test.tsx, new §7 one pair of reads per page, however many readers: two readers mounted together send each request once; a reader mounting after the answer joins it; a sys_api_key change re-reads that record once for both; a page mounted after every reader left reads afresh.
  • ui/apps/console/src/__tests__/App.listPageBootReadsOnce-28085.test.tsx (new, the card's acceptance pin): a list page (/apps/crm/crm_contact) loads through the real route tree with the boot main.tsx runs, the real preflightAuth, then App with the real AuthProvider, AuthGuard, ConnectedShell (real ObjectStackAdapter and MetadataProvider), RequireOrganization, the /me/permissions scope and LauncherAppsProvider, over one stubbed global fetch that records every URL. auth/get-session, meta/app, auth/me/permissions and me/apps are counted at exactly one request each. Only the app's own content and the pages off the route are stubbed, as in the sibling App.rootLandingReadsOnce-32633. No React.StrictMode, since a built console does not replay effects.
  • No existing test was edited.
Ablations (mutation through scripts/ablation-replace.mjs, restored to HEAD, git diff HEAD empty)
  • useLauncherApps.tsx: const state = firstReadDue ? PENDING : heldState; → const state = heldState; — 2 failed / 9 passed: a page behind the gate mounts once… ("expected vi.fn() to be called 1 times, but got 2 times") and is pending in the very first render… ("expected [ false ] to deeply equal [ true ]").
  • connectedAccess.ts: let entry = byUser.get(userId); → let entry: SharedReads | undefined = undefined; (one entry per reader) — 3 failed / 15 passed: two readers together, the late reader, and the re-read on change.
  • List-page pin, ui/packages/auth/src/createAuthClient.ts (takePreflightSession, the handoff that keeps the boot at one get-session): if (!slot || slot.taken) return null; → if (!slot || slot.taken || true) return null; — 1 failed / 0 passed: expected { 'auth/get-session': 2, …(3) } to deeply equal { 'auth/get-session': 1, …(3) }. Restored: blob == HEAD (ab510ed0c019), git diff HEAD empty.

Acceptance notes

Verification

All on head 1feba497 (merge base bc6b7ffd), after the last commit. The product files are unchanged since 76497be1; that round's app-shell checks (pnpm --filter @object-ui/app-shell type-check exit 0; cd ui && pnpm exec vitest run packages/app-shell/ --maxWorkers=2 under the verify lock, Test Files 2270 passed / 1 skipped, Tests 21007 passed / 9 skipped, exit 0) stand for them.

  • cd ui && pnpm exec vitest run apps/console/src/__tests__/App.listPageBootReadsOnce-28085.test.tsx apps/console/src/__tests__/App.rootLandingReadsOnce-32633.test.tsx, twice: 2 files, 3 tests passed each time (the new pin also passed alone once before the ablation).
  • pnpm --filter @object-ui/console type-check (covers the new test file) — exit 0.
  • Consumers of the two hooks (round 1, unchanged files): FirstRunChecklist.test.tsx and the console App.permissionsWave-29114, App.homePermissions-12700, App.rootLandingReadsOnce-32633, App.linkRefusalLanding-33063 suites — green.
  • node scripts/pm/dispatch-gates.mjs --ran on 1feba497 — 37 derived (the same 37 as round 1), 37 run, 0 NOT-MEASURED, 0 UNRUN; the whole round under the verify lock, every family exit 0 on the first run.
  • pnpm check:new-line-citations (ui) — 0 new citations.
  • Dogfood battery: not run — no ! in the title and no (narrowing) arm.
  • The CI families (Lint & Repo Gates, Type Check UI, Test UI, Build & E2E UI, the rest of the required set) are this PR's check-runs.
Derived gate ledger on 1feba49 (CMD :: exit)
node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0
node scripts/check-adr-0087-registration.mjs --self-test :: exit 0
node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0
node scripts/check-closing-keyword-parity.mjs :: exit 0
node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0
node scripts/check-comment-mask-corpus.mjs :: exit 0
node scripts/check-empty-changeset.mjs --base origin/main :: exit 0
node scripts/check-empty-changeset.mjs --self-test :: exit 0
node scripts/check-sdui-manifest.mjs :: exit 0
node scripts/check-sdui-manifest.mjs --self-test :: exit 0
node scripts/ci/snapshot-next.mjs --self-test :: exit 0
node scripts/pm/check-governed-queue-guard.mjs --self-test :: exit 0
node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0
node scripts/release-pending-publish.mjs --self-test :: exit 0
pnpm --dir ui exec vitest run scripts/ :: exit 0
pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0
pnpm check:changeset-gate-self-tests :: exit 0
pnpm check:closed-ceremony-text :: exit 0
pnpm check:cross-package-test-inputs :: exit 0
pnpm check:dispatcher-error-vocabulary :: exit 0
pnpm check:driver-memory-census :: exit 0
pnpm check:engine-double-contract :: exit 0
pnpm check:gitlink-declared :: exit 0
pnpm check:nul-bytes :: exit 0
pnpm check:published-files :: exit 0
pnpm check:query-options-erasure :: exit 0
pnpm check:refd-timer-probe :: exit 0
pnpm check:registry-log-declared :: exit 0
pnpm check:rest-log-spy-declared :: exit 0
pnpm check:skill-identifier-liveness :: exit 0
pnpm check:test-source-alias :: exit 0
pnpm check:tier-file-adoption :: exit 0
pnpm check:type-check-coverage :: exit 0
pnpm check:type-check-debt :: exit 0
pnpm check:undeclared-dep-imports :: exit 0
pnpm check:watch-hint-literal :: exit 0
pnpm check:where-matcher :: exit 0

Generated by Claude Code

…at makes it due

Home waits on the launcher's pending flag, but the provider published
pending only from its effect, after the first commit. Home therefore drew
its page for one frame, swapped it for the loading state, then drew it
again, mounting the deployment notice and the connect-assistant card twice
and sending their reads twice per load.

Claude-Session: https://claude.ai/code/session_01ADHkmPiLw38ErmCpnkcQvh
Co-authored-by: Claude <noreply@anthropic.com>
… of reads

Home mounts the Connect an AI Assistant card and the administrator's
checklist together, and each reader owned its own effect, so the
authorized-clients and sys_api_key reads went out once per reader. The
reads now live in a store shared by every reader mounted at the same time,
re-read on a change to either record, and dropped with the last reader.

Claude-Session: https://claude.ai/code/session_01ADHkmPiLw38ErmCpnkcQvh
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 15, 2026
…boot reads

A list page through the real route tree, real preflight and real
AuthProvider, over one recording fetch: auth/get-session, meta/app,
auth/me/permissions and me/apps go out once each.

Claude-Session: https://claude.ai/code/session_01ADHkmPiLw38ErmCpnkcQvh
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/l and removed size/m labels Nov 15, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#2 · os-steve · session_01ADHkmSzhXR4yUAgwq1bQRi

维护者速读

席位意见

修复在根因处(首帧 pending + 共享 store),而非在调用方加节流;钉子覆盖首页与列表页两条 boot 路径,消融证明有效。同意落地。

席位核对 — ACCEPT · domain:ui#2 · head 908e962 · 2026-11-15T19:21Z

A commit outside act flushes passive effects on a later task, so the page
in the DOM did not yet mean its child's read had run: under a loaded run
the launcher case read 0. The gate case now answers /me/apps by hand,
waits for the child's read and lets the load run out before counting
exactly one; the list-page pin waits for all four reads before counting.

Claude-Session: https://claude.ai/code/session_01ADHkmPiLw38ErmCpnkcQvh
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

Relay pr_dequeue · session_01ADHkmSzhXR4yUAgwq1bQRi · request fw-20261115T220702Z-cb2ece

Merge-queue dequeue of #34097 — cause seat-asks.

The relay sends dequeuePullRequest after this comment and confirms the removal by reading the queue back; the run row of this request carries the outcome. Re-queue once the cause is fixed (landing-operations.md, the landing seat's queue duty).

@objectstack-fleet
objectstack-fleet Bot removed this pull request from the merge queue due to a manual request Nov 15, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#2 · os-steve · session_01ADHkmSzhXR4yUAgwq1bQRi

维护者速读

席位意见

时序竞争在钉子本身,修法是在计数前等待因果上的前置事件,而不是放宽断言;消融证明钉子仍然有效。同意重新落地;落地后关闭 #34150。

席位核对 — ACCEPT · domain:ui#2 · head 00d8090 · 2026-11-15T23:25Z

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/l tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Console list page load sends get-session, meta/app, me/permissions and me/apps twice each, concurrently

2 participants